<?php


namespace api\blog\validate;


use think\Validate;

class UserValidate extends Validate
{
    //定义验证规则
    protected $rule = [
        'mobile' => 'require|mobile',//|unique:user
        'code' => 'require',
        'name' => 'require|max:10',
        'image' => 'image'
    ];
    //定义验证失败时的提示信息
    protected $message = [
        'mobile.require' => '手机号不能为空',
        'mobile.mobile' => '手机号格式错误',
        'name.require' => '用户名为必填',
        'name.max:10' => '用户名最大长度为10',
        'image.image' => '头像格式错误',
        'id.require' => 'id不能为空'
    ];

    //验证场景
    protected  $scene = [
        'register' => ['mobile'],
        'login' => ['mobile','code'],
        'add' => ['mobile','name','image'],
    ];
}